package GUI.cmd;

import i18n.JButtonI18N;

import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;

import GUI.GUI;
import GUI.common.ExceptionI18N;
import GUI.common.cmd.ClientCommand;
import GUI.forms.FAnalyzer;
import GUI.forms.FAnalyzerProgress;
import engine.Analyzer;



public class StartAnalyze implements ClientCommand {

	public void execute(GUI gui, ActionEvent source) throws ExceptionI18N {				
		JButtonI18N button = (JButtonI18N)source.getSource();
		FAnalyzer form = (FAnalyzer)button.getForm();
		
		ArrayList<File> books = new ArrayList<File>();
		books.add(new File("./books/book.bin"));
		books.add(new File("./books/varied.bin"));
		
		int totalTime = Integer.parseInt(form.getjTTime().getText());
		totalTime=totalTime*60000;
		
		Analyzer an = new Analyzer(form.getSelectedGame(), form.getSelectedEngine(), books, totalTime, Integer.parseInt(form.getjTErrorLimit().getText()), Integer.parseInt(form.getjTBorder().getText()), Integer.parseInt(form.getjTMaxMistakes().getText()), form.getjLDestinationFile().getText());
		
		FAnalyzerProgress fap = new FAnalyzerProgress(gui, an);
		
		gui.setContentPane(fap);
		fap.start();
	}

}